﻿<%@ Page Title="Formula" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Formulapage.aspx.cs" Inherits="TestJQGrid.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style2
        {
            width: 142px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:Label ID="lblMenuName" runat="server"></asp:Label>
<table style="width:100%;">
    <tr>
        <td align="left" valign="top" style="width:15%;border:1px solid;">
            <asp:DataList ID="dlFormula" runat="server" RepeatColumns="1" 
                RepeatDirection="Vertical" CellPadding="2" DataKeyField="ID" 
                >
                <ItemTemplate>
                    <asp:LinkButton ID="lbt_formula" 
                        Text='<%# DataBinder.Eval(Container.DataItem,"FormulaName") %>' CommandArgument='<%# Eval("ID") %>' runat="server" 
                        onclick="lbt_formula_Click">LinkButton</asp:LinkButton>
                </ItemTemplate>
            </asp:DataList>
        </td>
        <td align="left" valign="top" style="width:85%;border:1px solid;">
            <asp:HiddenField ID="currentControl" runat="server" Value="MainContent_txtWhenPart" />
    <asp:HiddenField ID="tableNames" runat="server" />
    <div style="width:100%;height:auto;">
    <table width="100%" style="float:left;">    
        <tr>
            <td class="style2">Name :</td>
            <td><asp:TextBox ID="txtFurmulaName" Width="250px" runat="server"></asp:TextBox></td>            
        </tr>
        <tr>
            <td>Return Type :</td>
            <td>
                <asp:DropDownList ID="ddReturnType" runat="server">                    
                    <asp:ListItem Text="Number" Selected="True" Value="number"></asp:ListItem>
                    <asp:ListItem Text="Date" Value="date"></asp:ListItem>
                    <asp:ListItem Text="String" Value="string"></asp:ListItem>
                    <asp:ListItem Text="Bool" Value="bool"></asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td colspan=2 class="style2">Input Parameters : </td>
        </tr>        
        <tr>
            <td colspan=2>
               <table style="margin-left:142px;width:auto;">
                <tr>
                    <td><asp:HiddenField ID="hf_1" runat="server" />
                        <asp:CheckBox ID="cb_1" runat="server" Text="" AutoPostBack="True" 
                            oncheckedchanged="cb_1_CheckedChanged" />
                    </td>
                    <td>
                        Parameter Name :
                    </td>
                    <td>
                        <asp:TextBox ID="parm_1" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                        Data type :
                    </td>
                    <td>
                        <asp:DropDownList ID="ddReturnType_1" runat="server">                    
                            <asp:ListItem Text="Number" Selected="True" Value="number"></asp:ListItem>
                            <asp:ListItem Text="Date" Value="date"></asp:ListItem>
                            <asp:ListItem Text="String" Value="string"></asp:ListItem>
                            <asp:ListItem Text="Bool" Value="bool"></asp:ListItem>
                        </asp:DropDownList>
                    </td>                                        
                </tr>
                <tr>
                    <td><asp:HiddenField ID="hf_2" runat="server" />
                        <asp:CheckBox ID="cb_2" runat="server" Text="" AutoPostBack="True"
                            oncheckedchanged="cb_2_CheckedChanged" />
                    </td>
                    <td>
                        Parameter Name :
                    </td>
                    <td>
                        <asp:TextBox ID="parm_2" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                        Data type :
                    </td>
                    <td>
                        <asp:DropDownList ID="ddReturnType_2" runat="server">                    
                            <asp:ListItem Text="Number" Selected="True" Value="number"></asp:ListItem>
                            <asp:ListItem Text="Date" Value="date"></asp:ListItem>
                            <asp:ListItem Text="String" Value="string"></asp:ListItem>
                            <asp:ListItem Text="Bool" Value="bool"></asp:ListItem>
                        </asp:DropDownList>
                    </td>                                        
                </tr>
                <tr>
                    <td><asp:HiddenField ID="hf_3" runat="server" />
                        <asp:CheckBox ID="cb_3" runat="server" Text="" AutoPostBack="True"
                            oncheckedchanged="cb_3_CheckedChanged" />
                    </td>
                    <td>
                        Parameter Name :
                    </td>
                    <td>
                        <asp:TextBox ID="parm_3" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                        Data type :
                    </td>
                    <td>
                        <asp:DropDownList ID="ddReturnType_3" runat="server">                    
                            <asp:ListItem Text="Number" Selected="True" Value="number"></asp:ListItem>
                            <asp:ListItem Text="Date" Value="date"></asp:ListItem>
                            <asp:ListItem Text="String" Value="string"></asp:ListItem>
                            <asp:ListItem Text="Bool" Value="bool"></asp:ListItem>
                        </asp:DropDownList>
                    </td>                                        
                </tr>
                <tr>
                    <td><asp:HiddenField ID="hf_4" runat="server" />
                        <asp:CheckBox ID="cb_4" runat="server" Text="" AutoPostBack="True"
                            oncheckedchanged="cb_4_CheckedChanged" />
                    </td>
                    <td>
                        Parameter Name :
                    </td>
                    <td>
                        <asp:TextBox ID="parm_4" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                        Data type :
                    </td>
                    <td>
                        <asp:DropDownList ID="ddReturnType_4" runat="server">                    
                            <asp:ListItem Text="Number" Selected="True" Value="number"></asp:ListItem>
                            <asp:ListItem Text="Date" Value="date"></asp:ListItem>
                            <asp:ListItem Text="String" Value="string"></asp:ListItem>
                            <asp:ListItem Text="Bool" Value="bool"></asp:ListItem>
                        </asp:DropDownList>
                    </td>                                        
                </tr>
                <tr>
                    <td><asp:HiddenField ID="hf_5" runat="server" />
                        <asp:CheckBox ID="cb_5" runat="server" Text="" AutoPostBack="True"
                            oncheckedchanged="cb_5_CheckedChanged" />
                    </td>
                    <td>
                        Parameter Name :
                    </td>
                    <td>
                        <asp:TextBox ID="parm_5" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                        Data type :
                    </td>                    
                    <td>
                        <asp:DropDownList ID="ddReturnType_5" runat="server">                    
                            <asp:ListItem Text="Number" Selected="True" Value="number"></asp:ListItem>
                            <asp:ListItem Text="Date" Value="date"></asp:ListItem>
                            <asp:ListItem Text="String" Value="string"></asp:ListItem>
                            <asp:ListItem Text="Bool" Value="bool"></asp:ListItem>
                        </asp:DropDownList>
                    </td>                    
                </tr>
               </table>
            </td>
        </tr>
        <tr>
            <td class="style2">When part</td>
            <td><asp:TextBox Rows=5 runat="server" Width="400px" ID="txtWhenPart" TextMode="MultiLine" onClick='return setCurrentControl("MainContent_txtWhenPart","MainContent_currentControl")'></asp:TextBox> 
                <asp:Label ID="lblWhenExp" runat="server"></asp:Label>
            </td>            
        </tr>
        <tr>
            <td class="style2">Then part</td>
            <td><asp:TextBox Rows=5 runat="server" Width="400px" ID="txtThenPart" TextMode="MultiLine" onClick='return setCurrentControl("MainContent_txtThenPart","MainContent_currentControl")'></asp:TextBox> 
                <asp:Label ID="lblThenExp" runat="server"></asp:Label>
            </td>            
        </tr>
        <tr>
            <td class="style2">&nbsp;</td>
            <td align="center">            
            <div id="div_formula" style="float:left;width:auto;margin-right:15px;">
            <b style="float:left;">Function List:</b><br />
                <asp:ListBox SelectionMode="Single" CssClass="smallbutton" ID="listFormula" Rows=6 runat="server" onClick='return selectoperator(this.value,"MainContent_currentControl");'></asp:ListBox>
            </div>
            <div id="div_fields" style="float:left;width:auto;margin-right:15px;">
            <b style="float:left;">Field List :</b><br />
                <asp:ListBox SelectionMode="Single" CssClass="smallbutton" ID="listFields" Rows=6 runat="server" 
                    onClick='return selectoperator(this.value,"MainContent_currentControl");'></asp:ListBox>
            </div>            
            <div id="div_operator" style="float:left;width:auto;">
            <b style="float:left;">Operators :</b><br />
                <table class="buttonList" cellpadding="0" cellspacing="1" style="width: 100px;">
                                <tr>
                                    <td>
                                        <input class="smallbutton" type="button" value="+" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value="-" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value="*" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value="/" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <input class="smallbutton" type="button" value="(" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value=")" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value="=" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value="!=" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <input class="smallbutton" type="button" value="<" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value=">" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value="<=" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value="=>" onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <input class="smallbutton" type="button" value="," onclick='return selectoperator(this.value,"MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value="AND" onclick='return selectoperator("&&","MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value="OR" onclick='return selectoperator("||","MainContent_currentControl");' />
                                    </td>
                                    <td>
                                        <input class="smallbutton" type="button" value="NOT" onclick='return selectoperator("!","MainContent_currentControl");' />
                                    </td>
                                </tr>
                            </table>
                </div>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td align="left">
                <asp:Button ID="btnValidate" runat="server" Text="Validate" 
                    onclick="btnValidate_Click" OnClientClick="return validateForm();" />&nbsp;&nbsp;
                <asp:Button ID="btnReset" runat="server" Text="Reset" 
                    onclick="btnReset_Click" />&nbsp;&nbsp;
                <asp:Button runat="server" ID="btnSave" Text="Save Formula" 
                    onclick="btnSave_Click" />
            </td>
        </tr>
    </table>
</div>
        </td>
    </tr>
</table>    
</asp:Content>

